package com.hkjt.springmvc.controller;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.hkjt.springmvc.Person;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import static org.springframework.web.bind.annotation.RequestMethod.*;

@Controller
public class HelloController {


    @RequestMapping(value = "/",params = {"add"})
    @ResponseBody
    public String hello(){
        return "Hello!";
    }



    //不含ID的post请求表示新增，包含ID的请求表示更新
    @RequestMapping(value = "/users",method = POST)
    @ResponseBody
    public String create(){
        return "create!";
    }

    @RequestMapping(value = "/users",method = POST,params = {"ID"})
    @ResponseBody
    public String update(){
        return "update!";
    }

    @RequestMapping(value = "/hello")
    public ResponseEntity helloResponse(){
        Person person = new Person("A","B","C");
        ResponseEntity<Person> responseEntity = new ResponseEntity<>(person,HttpStatus.CREATED);
        return responseEntity;
    }



}
